package br.ufc.minijavaufc;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;

import br.ufc.minijavaufc.parser.MiniJavaParser;

public class Main {

	public static void main(String[] args) {
		try
		{

			ArrayList<String> files = new ArrayList<String>();
			files.add("BinarySearch");
			files.add("BinaryTree");
			files.add("BubbleSort");
			files.add("LinearSearch");
			files.add("Factorial");
			files.add("LinearSearch");
			files.add("LinkedList");
			files.add("QuickSort");
			files.add("TreeVisitor");

			BufferedReader reader;
			MiniJavaParser parser;

			for (String fileName : files) {
				System.out.print(new StringBuilder().append("Compilando ").append(fileName).append("... "));
				reader = new BufferedReader(new FileReader(new StringBuilder().append(fileName).append(".java").toString()));
				parser = new MiniJavaParser(reader);
				try {
					parser.program();
					System.out.println("OK");
				} catch (Exception e) {
					System.out.println("Erro na compilação");
					System.out.println(e.getMessage());
				}
			}
		} catch (Exception e) {
//			e.printStackTrace();
		}
	}
}
